package com.zxc.controller.data;

import com.zxc.entity.Product;
import com.zxc.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping(value = "/productInformation")
public class ProductInformationController {

    @Autowired
    private ProductService productService;


    @RequestMapping("/{skipCount}/{pageSize}")
    @ResponseBody
    public Map<String,Object> getProductListOrByCustName(@PathVariable Integer skipCount,
                                                         @PathVariable Integer pageSize){
        Map<String,Object> modelMap = new HashMap<>();
        int skipCounts = (skipCount-1)*pageSize;
        List<Product> sctServiceList  = productService.getProductList(skipCounts,pageSize);
        modelMap.put("dataList",sctServiceList);
        int total = productService.selectProductCount();
        modelMap.put("total",total);
        return modelMap;
    }


}
